package action;

import java.util.Map;

import com.opensymphony.xwork2.ActionContext;

import action.base.BaseAction;

public class RegistAction extends BaseAction {
	private String user;
	private String pass;
	private String identity;
	private String email;
	private String realName;
	private String gender;
	private String tel;
	private String vercode;
	private int power;
	private String tip;
	public String getTip() {
		return tip;
	}

	public void setTip(String tip) {
		this.tip = tip;
	}

	public String getIdentity() {
		return identity;
	}

	public void setIdentity(String identity) {
		this.identity = identity;
	}

	public String getRealName() {
		return realName;
	}

	public void setRealName(String realName) {
		this.realName = realName;
	}

	public String getGender() {
		return gender;
	}

	public void setGender(String gender) {
		this.gender = gender;
	}

	public String getTel() {
		return tel;
	}

	public void setTel(String tel) {
		this.tel = tel;
	}

	public String getVercode() {
		return vercode;
	}

	public void setVercode(String vercode) {
		this.vercode = vercode;
	}

	public String getUser() {
		return user;
	}

	public void setUser(String user) {
		this.user = user;
	}

	public String getPass() {
		return pass;
	}

	public void setPass(String pass) {
		this.pass = pass;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String execute() throws Exception {
		Map session = ActionContext.getContext().getSession();
		String ver = (String) session.get("rand");
		session.put("rand", null);
		session.put("user", getUser());
		if (vercode.equals(ver)) {
			power = 0;
			if (mgr.addUser(user, pass,identity, email,realName,gender,tel,power) > 0) {
				return SUCCESS;
			} else {
				setTip("注册失败，请重试！");

			}
		} else {
			setTip("验证码不匹配，请重新输入");
		}
		return "failure";
	}

}
